'''
Created on 02/06/2010

@author: Glazner
'''
import unittest
from wp.client import Task
import time

class TestTask(unittest.TestCase):
    
    def callback(self,res):
        self.res = res

    def setUp(self):
        self.func = 'some_method_name'
        self.args = (1,2,3)
        self.group = 'some_group'
        self.task= Task(self.func, self.args, self.callback,self.group)


    def tearDown(self):
        pass


    def test__init__(self):
        self.assertEqual(self.task.func,self.func)
        self.assertEqual(self.task.args,self.args)
        self.assertEqual(self.task.callback,self.callback)
        self.assertEqual(self.task.group,self.group)
        self.assertEqual(self.task.res,None)
        
    def testFinish(self):
        self.task.finish(3)
        time.sleep(3)#since finish is a threaded function
        self.assertEqual(3,self.res) #testing the call back
        self.assertEqual(3,self.task.res)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()